﻿@{
   
}
@section head{
}
<div class="rightbar">
    <p class="righttit">
        <span>管理中心</span></p>
    <div class="rightshow">
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabtit">
            <tr>
                <td width="10%" align="center">
                    <a href="@Url.Action("IndustryDetail")">
                        <img alt="" src="@Url.Content("~/Areas/admin/image/add.jpg")" />
                        添加行业分类</a>
                </td>
                <td>
                    &nbsp;
                </td>
            </tr>
        </table>
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tinfor1">
            <tr class="tinfor2">
                <td width="3%">
                    <input type="checkbox" name="checkbox" />
                </td>
                <td>
                    ID
                </td>
                <td>
                    分类级别
                </td>
                <td>
                    行业名称名称
                </td>
                <td>
                    操作
                </td>
            </tr>
            @helper renderProType(string pid)
                {
                    System.Data.DataView dv = new System.Data.DataView(@Model);
                    dv.RowFilter = "[parentId]=" + pid;

                    foreach (System.Data.DataRowView drv in dv)
                    {
                        string id = drv["id"].ToString();
                        drv["IndustryName"] = drv["IndustryName"];
                <tr class="tinfor3">
                    <td>
                        <input type="checkbox" name="checkbox" id="checkbox" />
                    </td>
                    <td>
                        @drv["Id"]
                    </td>
                    <td>
                       @drv["LeveId"] 级分类
                    </td>
                    @if (@drv["counts"].ToString() != "0")
                    {
                        <td align="left" style="padding-left: 30px">
                            <img src="@Url.Content("~/Areas/admin/image/bullet_toggle_minus.png")" />
                            @MvcHtmlString.Create(@drv["IndustryName"].ToString())
                        </td>
                    }
                    else
                    {
                        <td align="left" style="padding-left: 30px">
                            <img src="@Url.Content("~/Areas/admin/image/list.png")" />&nbsp;&nbsp;
                            @MvcHtmlString.Create(@drv["IndustryName"].ToString())
                        </td>
                    }
                    <td>
                        <span><a href="@Url.Action("IndustryDetail", new { Id = @id })">编辑</a></span>&nbsp;&nbsp;<span>
                            <a href="###" onclick="oDelete(@drv["Id"])">删除</a></span>
                    </td>
                </tr>
                @renderProType(id);
                    }
            }
            @renderProType("0")
        </table>
    </div>
</div>
@section Script{
    <script type="text/javascript">

        function oDelete(obj) {
            art.dialog.confirm('你确定要删除吗？', function () {
                doDelete(obj);
            }, function () {

            });
        }
        function doDelete(obj) {
            $.ajax({
                type: "POST",
                url: "/Admin/ProMgr/IndustryDelete",
                data: { "id": obj },
                dataType: "text",
                success: function (msg) {
                    if (msg == "1") {
                        location.reload();
                    }
                    else {
                        art.dialog({
                            title: "提示",
                            icon: "warning",
                            content: "操作失败！",
                            time: 2
                        });
                    }
                },
                error: function () {
                    art.dialog({
                        title: "提示",
                        icon: "warning",
                        content: "网络忙，请稍后再试！",
                        time: 2
                    });
                }
            });
        }

//        $(function () {
//            $(".Sort").each(function () {
//                $(this).blur(function () {
//                    var id = $(this).attr("id");
//                    var value = $(this).attr("value");
//                    oSort(id, value);
//                });
//            });
//        });

//        //排序
//        function oSort(id, value) {
//            $.ajax({
//                type: "POST",
//                url: "/Admin/ProMgr/ProTypeSort",
//                data: { "id": id, "value": value },
//                dataType: "text",
//                success: function (msg) {
//                    if (msg == "1") {
//                        alert("操作成功");
//                    }
//                    else {
//                        alert("操作失败");
//                    }
//                },
//                error: function () {
//                    art.dialog({
//                        title: "提示",
//                        icon: "warning",
//                        content: "网络忙，请稍后再试！",
//                        time: 2
//                    });
//                }
//            });
//        }
    </script>
}
